package top.loonglove.bean;

import top.loonglove.status.ElementType;

import java.util.Objects;

/**
 * @author 向贵龙
 * @date 2021/7/12
 * 有结尾符的标，例如：``:code-block标签 **xx**:bold标签
 */
public class DoubleElement extends AbstractElement {
    /**
     * 标签前缀
     */
    private String prefix;
    /**
     * 标签后缀
     */
    private String suffix;

    public DoubleElement(String prefix,String value,  String suffix) {
        super(value);
        this.prefix = prefix;
        this.suffix = suffix;
    }

    public DoubleElement(String prefix, String value, String suffix, ElementType type) {
        super(value, type);
        this.prefix = prefix;
        this.suffix = suffix;
    }

    public DoubleElement() {
        super();
    }

    public String getPrefix() {
        return prefix;
    }

    public void setPrefix(String prefix) {
        this.prefix = prefix;
    }

    public String getSuffix() {
        return suffix;
    }

    public void setSuffix(String suffix) {
        this.suffix = suffix;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        DoubleElement that = (DoubleElement) o;
        return Objects.equals(prefix, that.prefix) && Objects.equals(suffix, that.suffix);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), prefix, suffix);
    }

    @Override
    public String toString() {
        return String.format("%s%s%s",prefix,value,suffix);
    }
}
